﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Maticsoft.DBUtility;

namespace ElingOA6_Admin_DSJCJ.DAL
{
    /// <summary>
    /// 库存报警数据层
    /// </summary>
    public partial class ItemInventoryAlarm
    {
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public DataSet GetAll()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select * from dbo.t_Item where FQty <= FSafetyStock");

            return DbHelperSQL.Query(strSql.ToString());
        
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="itemName"></param>
        /// <returns></returns>
        public DataSet GetByItemNo(string itemNo)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select *  from");
            strSql.Append(" (select * from dbo.t_ItemRequisitionApplyEntry");
            if (itemNo != "")
            {
                strSql.Append(" where FItemNo= '" + itemNo + "'");
            }
            strSql.Append(" ) AS a ");
            strSql.Append(" inner join dbo.t_ItemRequisitionApply AS b");
            strSql.Append(" ON a.FItemRequisitionApplyID=b.FItemRequisitionApplyID");
            strSql.Append(" WHERE FStatus <> 'A' ");

            return DbHelperSQL.Query(strSql.ToString());
        }

    }
}
